//
//  DRMineDataModel.m
//  DoctorRen
//
//  Created by Macx on 2018/11/20.
//

#import "DRMineDataModel.h"
#import "DRMineModel.h"

@implementation DRMineDataModel

+(void)loadMineDataWithSuccess:(void (^)(DRMineModel * _Nonnull))succBlock andFail:(RequestFail)failBlock {
    
    [[DRHttpTool shared] POST:DRURL(@"index.php/Apiucenter/index.html") andParams:@{@"token": [DRLoginDataModel getUserToken]} andSucc:^(id  _Nonnull data) {
        
        if (succBlock) {
            DRMineModel *model = [DRMineModel yy_modelWithJSON:data];
            succBlock(model);
        }
    } andFail:^(NSError * _Nonnull error) {
        if (failBlock) {
            failBlock(error);
        }
    }];
    
}

+(void)saveDeviceDataWith:(NSString *)weight sugar:(NSString *)sugar presure:(NSString *)presure success:(nonnull void (^)(void))succBlock andFail:(nonnull RequestFail)failBlock{
    NSDictionary *params = @{
                             @"weight": weight,
                             @"sugar": sugar,
                             @"pressure": presure,
                             @"token": [DRLoginDataModel getUserToken]
                             };
    [[DRHttpTool shared] POST:DRURL(@"index.php/Apiucenter/devicesave.html") andParams:params andSucc:^(id  _Nonnull data) {
        if (succBlock) {
            succBlock();
        }
    } andFail:failBlock];
    
}

+(void)submitScore:(NSInteger)socre success:(void (^)(void))succBlock andFail:(RequestFail)failBlock{
    
    NSDictionary *params = @{
                             @"socre": [@(socre) stringValue],
                             @"token": [DRLoginDataModel getUserToken]
                             };
    
    [[DRHttpTool shared] new_POST:DRURL(@"index.php/NewUcenter/score") andParams:params andSucc:^(id  _Nonnull data) {
        if (succBlock) {
            succBlock();
        }
    } andFail:failBlock];
    
}

@end
